// Copyright 2021 Guoyoko. All Rights Reserved.

#include "SWDetailBuilderModule.h"
#include "Modules/ModuleManager.h"
#include "SSWDetailPanelContainer.h"
#include "SWGameViewportClientModule.h"
#include "SWGameViewportClient.h"


void FSWDetailBuilderModule::StartupModule()
{
    SAssignNew(DetailPanelContainer, SSWDetailPanelContainer);

    FCoreUObjectDelegates::PostLoadMapWithWorld.AddRaw(this, &FSWDetailBuilderModule::OnPostLoadMap);
}

void FSWDetailBuilderModule::ShutdownModule()
{
}

void FSWDetailBuilderModule::OnPostLoadMap(UWorld* LoadedWorld)
{
	if (GVC)
	{
		GVC->DelegateOnSelectedActor.AddSP(DetailPanelContainer.Get(), &SSWDetailPanelContainer::CallBack_ActorSelected);
	}

	DetailPanelContainer->Initialize();
}

TSharedPtr<class SWidget> FSWDetailBuilderModule::BuildPropertyPanel()
{
	if(DetailPanelContainer)
		return DetailPanelContainer;

	return SNullWidget::NullWidget;
}


IMPLEMENT_MODULE(FSWDetailBuilderModule, SWDetailBuilder);

